

<meta charset="utf-8">
<div class="box" id="biz_pmpProject_detail_task_conatainer">
	<div class="box-header with-border">
		<form id="pmpProjectTaskSearchForm" role="form" class="form-inline">
			<div class="form-group">
				<label>任务名称</label> 
				<input name="name" v-model="searchForm.name" type="text" placeholder="" class="form-control">
			</div>
			<button type="button" class="btn btn-info pull-right m-t-n-xs" v-on:click="search">
				<strong>查询</strong>
			</button>
		</form>
	</div>
	<div class="box-body">
				<div class="btn-group " id="pmpProjectTaskTableToolbar" role="group">
					<button type="button" v-kperms="{perm:''}" class="btn btn-primary" v-on:click="add">
						<i class="glyphicon glyphicon-plus" aria-hidden="true"></i> 创建任务
					</button>
					<button type="button" v-kperms="{perm:''}" class="btn btn-infot" v-on:click="edit">
						<i class="glyphicon glyphicon-edit" aria-hidden="true"></i> 修改任务
					</button>
					<button type="button" v-kperms="{perm:''}" class="btn btn-primary" v-on:click="split">
						<i class="glyphicon glyphicon-plus" aria-hidden="true"></i> 拆分任务
					</button>
					
					<button type="button" v-kperms="{perm:''}" class="btn btn-warning" v-on:click="assign">
						<i class="glyphicon glyphicon-pencil" aria-hidden="true"></i> 指派任务
					</button>
				
					<button type="button" v-kperms="{perm:''}" class="btn btn-secondary" v-on:click="editVersion">
						<i class="glyphicon glyphicon-pencil" aria-hidden="true"></i> 修改版本
					</button>
					
					<button type="button" v-kperms="{perm:''}" class="btn btn-info" v-on:click="editWorkHours">
						<i class="glyphicon glyphicon-time" aria-hidden="true"></i> 添加工时
					</button>
					<button type="button" v-kperms="{perm:''}" class="btn btn-success" v-on:click="editExpireTime">
						<i class="glyphicon glyphicon-calendar" aria-hidden="true"></i> 截止日期
					</button>
					<button type="button" v-kperms="{perm:''}" class="btn btn-warning" v-on:click="createBug">
						<i class="glyphicon glyphicon-plus" aria-hidden="true"></i> 创建bug
					</button>
					<button type="button" v-kperms="{perm:''}" class="btn btn-danger" v-on:click="deletex">
						<i class="glyphicon glyphicon-trash" aria-hidden="true"></i> 删除任务
					</button>
					
					<button type="button" v-kperms="{perm:''}" class="btn btn-success" v-on:click="submit">
						<i class="glyphicon glyphicon-upload" aria-hidden="true"></i> 任务提交
					</button>
				</div>
				<table id="pmpProjectTaskBootstrapTable" data-mobile-responsive="true"></table>
	</div>
</div>
<script>
    
new Vue({  
	  el: '#biz_pmpProject_detail_task_conatainer',
	  data:{
		  searchForm:{
			  name: null,
			  pmUserId: null,
			  projectId : null,
		 },
		  bus:new Vue(),
	  },
	  mounted:function(){
		  var _this=this;
		  var projectId="3";
			_this.searchForm.projectId=projectId;
	      _this.initTable();
	  },
    methods: {
  	  initTable:function(){
  		var _this=this;
  		var columns=[
			{checkbox:true},
			{field:'task_name',title:'名称',width:160,sortable:true},
		    {field:'from_require',title:'源于需求',width:100,formatter:_this.formatType},
			{field:'charge_user_name',title:'负责人',width:100},
			{field:'priority',title:'优先级',width:100,formatter:_this.formatPriority},
			{field:'difficulty_score',title:'难度',width:100},
			{field:'assign_hours',title:'指派时间',width:100},
			{field:'work_hours',title:'工作时间',width:100},
			{field:'progress',title:'进度',width:100,formatter:_this.formatProgress},
			{field:'expiry_time',title:'截止时间',width:100},
			{field:'status',title:'状态',width:100,formatter:_this.formatStatus},
			{field:'expired',title:'状态',width:100,formatter:_this.formatExpired},
			{field:'expired',title:'操作',width:100,formatter:_this.formatEntry}];
			
  
  
     var url="/pmp/service/pm/pmpTasks/loadPmpTasksDataSet";
     zfesBstable.laodTable($("#pmpProjectTaskBootstrapTable"),$("#searchForm"),$("#pmpProjectTaskBootstrapTable"),url,columns,this.searchForm);
  	  },
  	  search:function(){
  		  zfesBstable.reload($("#pmpProjectTaskBootstrapTable")); 
  	  },
  	  refresh:function(){
  		  zfesBstable.refresh($("#pmpProjectTaskBootstrapTable"));
  	  },
  	  add:function(){
  		 var　_this=this;
 		var url="/views/pmpTasks/pmpTasks.add.html";
 		zfesLayerEditDg.open(url,{"projectId": _this.searchForm.projectId,"projectVersionId": _this.searchForm.projectVersionId},"添加任务",660,function(){_this.refresh();}); 
 		 
  		 
  	  },
  	  edit:function(){
  		  if(zfesBstable.isOneRow($("#pmpProjectTaskBootstrapTable"))){
  			  var　_this=this;
  			  var id=zfesBstable.getRowId($("#pmpProjectTaskBootstrapTable"));
  			var url="/views/pmpTasks/pmpTasks.edit.html";
  	 		zfesLayerEditDg.open(url,{"id":id},"任务信息编辑",660,function(){_this.refresh();});
  		 }
  	  },
  	 createBug:function(){
 		  if(zfesBstable.isOneRow($("#pmpProjectTaskBootstrapTable"))){
 			  var　_this=this;
 			  var id=zfesBstable.getRowId($("#pmpProjectTaskBootstrapTable"));
 			var url="/views/pmpBugs/pmpBugs.addFromTask.html";
 	 		zfesLayerEditDg.open(url,{"id":id},"创建任务bug",660,function(){_this.refresh();});
 		 }
 	  },
  	 editVersion:function(){
 		  if(zfesBstable.isOneRow($("#pmpProjectTaskBootstrapTable"))){
 			  var　_this=this;
 			  var id=zfesBstable.getRowId($("#pmpProjectTaskBootstrapTable"));
 			  var url="/views/pmpTasks/pmpTasks.editVersion.html";
 			  zfesLayerEditDg.open(url,{"id":id},"任务所属项目版本修改",460,function(){_this.refresh();}); 
 		 }
 	  },
 	 assign:function(){
 		  if(zfesBstable.isOneRow($("#pmpProjectTaskBootstrapTable"))){
 			  var　_this=this;
 			  var id=zfesBstable.getRowId($("#pmpProjectTaskBootstrapTable"));
 			  var url="/views/pmpTasks/pmpTasks.assign.html";
 			  zfesLayerEditDg.open(url,{"id":id},"任务指派",460,function(){_this.refresh();}); 
 		 }
 	  },
 	 editExpireTime:function(){
 		  if(zfesBstable.isOneRow($("#pmpProjectTaskBootstrapTable"))){
 			  var　_this=this;
 			  var id=zfesBstable.getRowId($("#pmpProjectTaskBootstrapTable"));
 			  var url="/views/pmpTasks/pmpTasks.editExpireTime.html";
 			  zfesLayerEditDg.open(url,{"id":id},"任务截止时间修改",460,function(){_this.refresh();}); 
 		 }
 	  },
 	 editWorkHours:function(){
		  if(zfesBstable.isOneRow($("#pmpProjectTaskBootstrapTable"))){
			  var　_this=this;
			  var id=zfesBstable.getRowId($("#pmpProjectTaskBootstrapTable"));
			  var url="/views/pmpTasks/pmpTasks.editWorkHours.html";
			  zfesLayerEditDg.open(url,{"id":id},"添加任务工时",460,function(){_this.refresh();}); 
		 }
	  },
 	 split:function(){
 		  if(zfesBstable.isOneRow($("#pmpProjectTaskBootstrapTable"))){
 			  var　_this=this;
 			  var id=zfesBstable.getRowId($("#pmpProjectTaskBootstrapTable"));
 			  var url="/views/pmpTasks/pmpTasks.split.html";
 			  zfesLayerEditDg.open(url,{"taskId":id},"拆分任务",600,function(){_this.refresh();}); 
 		 }
 	  },
 	 submit:function(){
		  if(zfesBstable.isOneRow($("#pmpProjectTaskBootstrapTable"))){
			  var　_this=this;
			  var id=zfesBstable.getRowId($("#pmpProjectTaskBootstrapTable"));
			  var url="/views/pmpTasks/pmpTasks.submit.html";
			  zfesLayerEditDg.open(url,{"id":id},"提交任务",600,function(){_this.refresh();}); 
		 }
	  },
  	  deletex: function(){
  			if(zfesBstable.isSelectedRow($("#pmpProjectTaskBootstrapTable"))){
  				  var　_this=this;
  				    var id=zfesBstable.getRowId($("#pmpProjectTaskBootstrapTable"));
  					 alertSwal.confirm("删除","是否删除该任务",function(){
  						    var ajaxUrl = "/pmp/service/pm/pmpTasks/setPmpTasksStatus";
  							zfesAjax.ajaxTodo(ajaxUrl, { "id" : id,"status":-1}, function(data) {
  								alertSwal.successText(data.message);
  								_this.refresh();
  							}); 
  				});
  			}
  				
  	  },
  	
   	
 	  formatType:function(value, row, index){
 	  		if("1"==value){return '[是]';}else{return '[否]';}
 	  	},
 	  formatStatus:function(value, row, index){
 	   		if("1"==value){return '<span class="label label-info">未指派</span>';}
 	   		else if("2"==value){return '<span class="label label-info">未开始</span>';}
 	   		else if("3"==value){return '<span class="label label-primary">进行中</span>';}
 	   		else if("4"==value){return '<span class="label label-info">已提交</span>';}
 	   		else if("5"==value){return '<span class="label label-danger">被驳回</span>';}
 	   		else if("6"==value){return '<span class="label label-success">已完成</span>';}
 	   		else{return '<span class="label label-default">已删除</span>';}
 	   	},
 	   formatExpired:function(value, row, index){
	  		if("2"==value){return '<span class="label label-danger">已超时</span>';}
	  		else{return '<span class="label label-info">正常</span>';}
	  	},
	  	formatEntry: function(value, row, index){
	  		return '<button type="button" class="btn btn-link"  onClick="taskDetail('+row.id+')" ><i class="glyphicon glyphicon-eye-open" aria-hidden="true"></i></button>';
	  	},
	  	formatProgress:function(value, row, index){
	  		return '<div class="progress"><div class="progress-bar progress-bar-striped bg-info active" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 45%">30%</div></div>';
	   },
	   formatPriority:function(value, row, index){ 
	  		if("1"==value){return '[低]';}else if("2"==value){return '[中等]';}else if("3"==value){return '[急]';}else{return '[加急]';}
	  	}
	  
	 }
	});
    function taskDetail(id){
		  var url="/views/pmpTasks/pmpTasks.detail.html";
		  zfesLayerEditDg.open(url,{"id":id},"任务详情",600,function(){}); 
    }

</script>


